<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	
	
    public function _initAutoregister()
    {
    	
        require_once 'Zend/Loader/Autoloader.php';
		require_once 'Zend/Media/Id3v1.php';
		require_once 'Zend/Media/Id3v2.php';
        $autoloader = Zend_Loader_Autoloader::getInstance();
        //$autoloader->registerNamespace('System');
        $autoloader->setFallbackAutoloader(true);
    }
	
	function _initDb()
	{
//TODO:  move to config
		$dbParam = array(
							'host'     => '127.0.0.1',
    					    'username' => 'root',
    						'password' => '',
    					    'dbname'   => 'music',
						 );
		$db = Zend_Db::factory( 'Pdo_Mysql', $dbParam );
		$db->query( "SET NAMES 'utf8'" );
		
		
		
		
		Zend_Db_Table::setDefaultAdapter($db);
		
		Zend_Registry::set( 'dbAdapter', $db );
	}
	
	function _initAuth()
	{
		Zend_Controller_Front::getInstance()->registerPlugin(new AuthPlugin());
	}
	
	function _initRouters()
	{
		 $ctrl = Zend_Controller_Front::getInstance();
        $router = $ctrl->getRouter();
     
        
   $router->addRoute('download', new Zend_Controller_Router_Route(
      'download/:path',
      array(
        'module'    => 'default',
        'controller'  => 'files',
        'action'    => 'download'
      )
    ));
		
	}

}

